package com.foreknow.mapping;

import java.util.HashMap;
import java.util.Map;

/**
 * 工厂类
 */
public class MappingFactory {
    private static MappingFactory mappingFactory = null;
    private Map<String, EntityMapping> maps = new HashMap<>();
    public static final String ADMIN_MAPPING = "adminMapping";
    public static final String Sys_User_MAPPING = "sys_userMapping";
    //  public static final String USER_MAPPING = "adminMapping";

    private MappingFactory() {

    }

    public static MappingFactory getInstance() {
        if (mappingFactory == null) {
            mappingFactory = new MappingFactory();
            mappingFactory.maps.put(ADMIN_MAPPING, new AdminMapping());
            mappingFactory.maps.put(Sys_User_MAPPING,new Sys_UserMapping());
            //mappingFactory.maps.put(USER_MAPPING,new UserMapping());

        }
        return mappingFactory;
    }

    /**
     * 根据key从Map容器中获取到xxxMapping对象
     *
     * @param key
     * @return EntityMapping接口
     */
    public EntityMapping getMap(String key) {
        return maps.get(key); //获取到AdminMapping对象
    }

}
